package com.alawn.framework.core.web.faces.scope;

import java.util.Collection;
import java.util.Map;
import java.util.Set;

import javax.faces.context.FacesContext;
import javax.faces.context.Flash;

import org.springframework.stereotype.Component;

@Component("flashScope")
public class FlashScope implements Map<String, Object> {
	public void clear()
	  {
	    getFlash().clear();
	  }
	  
	  public boolean containsKey(Object key)
	  {
	    return getFlash().containsKey(key);
	  }
	  
	  public boolean containsValue(Object value)
	  {
	    return getFlash().containsValue(value);
	  }
	  
	  public Set<Map.Entry<String, Object>> entrySet()
	  {
	    return getFlash().entrySet();
	  }
	  
	  public Object get(Object key)
	  {
	    return getFlash().get(key);
	  }
	  
	  public boolean isEmpty()
	  {
	    return getFlash().isEmpty();
	  }
	  
	  public Set<String> keySet()
	  {
	    return getFlash().keySet();
	  }
	  
	  public Object put(String key, Object value)
	  {
	    return getFlash().put(key, value);
	  }
	  
	  public void putAll(Map<? extends String, ? extends Object> m)
	  {
	    getFlash().putAll(m);
	  }
	  
	  public Object remove(Object key)
	  {
	    return getFlash().remove(key);
	  }
	  
	  public int size()
	  {
	    return getFlash().size();
	  }
	  
	  public Collection<Object> values()
	  {
	    return getFlash().values();
	  }
	  
	  private Flash getFlash()
	  {
	    return 
	      FacesContext.getCurrentInstance().getExternalContext().getFlash();
	  }
}
